// HotAnalysisController.java
package com.scuec.groupfive.Controller;

import com.scuec.groupfive.entity.HotAnalysisResult;
import com.scuec.groupfive.service.HotAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/api/community/hot-analysis")
@CrossOrigin
public class HotAnalysisController {

    @Autowired
    private HotAnalysisService hotAnalysisService;

    @GetMapping
    public HotAnalysisResult getHotAnalysis(
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "10") int pageSize) {

        return hotAnalysisService.getHotAnalysis(startDate, endDate, page, pageSize);
    }
}